package com.woniu.rear.maintenance.business.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import com.woniu.rear.business.model.domain.RepairInfo;
import com.woniu.rear.business.model.param.RepairInfoParam;
import com.woniu.rear.comm.core.dto.ResponseEntity;
import com.woniu.rear.comm.web.util.BeanCopyUtil;
import com.woniu.rear.maintenance.business.facade.client.HousingMaterialFacade;
import com.woniu.rear.maintenance.business.facade.dto.HousingMaterialDto;
import com.woniu.rear.maintenance.business.web.service.RepairInfoService;

@RestController
public class HousingMaterialController {
	
	@Autowired
	private HousingMaterialFacade hmf;
	
	@Autowired
	private RepairInfoService repairInfoService;
	
	@GetMapping("/test")
	public ResponseEntity<List<HousingMaterialDto>> test() {
		return hmf.list();
	}
	
	@PostMapping("/save")
	public ResponseEntity<?> save(RepairInfoParam rip) {
		RepairInfo ri = BeanCopyUtil.copyObject(rip, RepairInfo::new);
		boolean result = repairInfoService.save(ri);
		return result?ResponseEntity.BuildSuccess():ResponseEntity.BuildError();
	}
	
	@GetMapping("/seataTest")
	public ResponseEntity<?> seataTest(Integer cont) {
		repairInfoService.seataService(cont);
		return ResponseEntity.BuildSuccess();
	}

}
